#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int arr[30];
string s;
int k;
int main()
{
	cin >> s;
	cin >> k;
	int ma = -100;
	for (int i = 0; i < 26; i++) {
		cin >> arr[i];
		ma = max(arr[i], ma);
	}
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		int id = s[i] - 'a';
		ans += (i + 1) * arr[id];
	}
	int i = s.size() + 1;
	while (k--) {
		ans += i * ma;
		i++;
	}
	cout << ans << endl;
	return 0;
}